package com.ffe.flower.engine.extend;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.ffe.flower.engine.wrapper.FlowStateWrapper;
import com.ffe.flower.engine.wrapper.FlowWrapper;

@Component
public class DefaultProcessLogger implements IProcessCommonLogger {

  private static final Logger log = LoggerFactory.getLogger(DefaultProcessLogger.class);

  @Override
  public void startProcess(FlowWrapper newFlowWrapper, FlowStateWrapper newStateWrapper) {
    log.info("Process Id : [{}] --- Flow Id : [{}] starts! Entering State [{}]", newFlowWrapper.getProcessId(),
        newFlowWrapper.getFlowId(), newStateWrapper.getFlowState());
  }

  @Override
  public void transit(FlowWrapper afterFlowWrapper, FlowStateWrapper afterStateWrapper,
      FlowStateWrapper newStateWrapper) {
    log.info("Process Id : [{}] --- Flow Id : [{}] continues! Leaving [{}] State With [{}] and entering State [{}]",
        afterFlowWrapper.getProcessId(), afterFlowWrapper.getFlowId(), afterStateWrapper.getStateId(),
        afterStateWrapper.getAuditStatus(), newStateWrapper.getFlowState());

  }

  @Override
  public void endProcess(FlowWrapper afterFlowWrapper, FlowStateWrapper afterStateWrapper,
      FlowStateWrapper newStateWrapper) {
    log.info("Process Id : [{}] --- Flow Id : [{}] ends! Leaving [{}] State With [{}] and entering State [{}]",
        afterFlowWrapper.getProcessId(), afterFlowWrapper.getFlowId(), afterStateWrapper.getStateId(),
        afterStateWrapper.getAuditStatus(), newStateWrapper.getFlowState());
  }

}
